<?php include_once("header.html")?>
<script src="<?php echo $www_site_url?>/public/js/calendar.js" type="text/javascript"></script>
<div id="append"></div>
<div id="wrap">  <br />

<?php include_once("home_left.html")?>

<div class="admincontent">
<div id="tabsD" style="width:100%">
  <ul>
   	<li <?php if($type=='summary') echo 'class="on"';?>><a href="/client.php/home/overall/summary"><span><?php echo lang("summary")?></span></a></li>
    <li <?php if($type=='yesorno') echo 'class="on"';?>><a href="/client.php/home/overall/yesorno"><span><?php echo lang("yesorno")?></span></a></li>
    <li <?php if($type=='vote') echo 'class="on"';?>><a href="/client.php/home/overall/vote"><span><?php echo lang("vote")?></span></a></li>
    <li <?php if($type=='time') echo 'class="on"';?>><a href="/client.php/home/overall/time"><span><?php echo lang("score")?></span></a></li>

    <li style="float:right;"><?php echo lang("select_brand")?>:<input name="selbrand" type="text" class="ClocationInput" onclick="showmitibrands();" id="selbrand" value="<?php if(isset($brand) && $brand){ echo splitx($brand['b_name']); }?>" /></li>
  </ul>
</div>
<br />
<br />

<div id="brandlist" style="width: 170px; border: 1px solid #B5CFD9; background:#fefefe;display:none; position:absolute;z-index:999;">
  <ul>
  <?php
       if(isset($brands) && is_array($brands)){
       ?>
       <li style="padding:2px;"> <label><a href="/client.php?action=home&view=overall&selbrands=-1"><?php echo "所有品牌";?></a></label></li>
       <?php
         foreach ($brands as $b){
                ?>
	<li style="padding:2px;"> <label><a href="/client.php?action=home&view=overall&selbrands=<?php echo $b['b_id']?>"><?php echo splitx($b['b_name']);?></a></label></li>
	  <?php
			}
      }
       ?>
     </ul>
</div>

<form action="/client.php" method="GET" name="seachfrm">
<input name="action" type="hidden" value="home"  />
 <input name="view" type="hidden" value="overall"  />
 <input name="overall" type="hidden" value="<?php echo $type?>"  />

<div id="storelist" style="width: 210px; border: 1px solid #B5CFD9; background:#fefefe;display:none; position:absolute;z-index:999;">
  <ul>
  <?php
       if(isset($stores) && is_array($stores)){
         foreach ($stores as $s){
                ?>
	<li style="padding:2px;"> <label><input onclick="selectmitilstore('<?php echo $s['cs_id']."|".$s['cs_name'];?>');" type="checkbox" name="selstores[]" value="<?php echo $s['cs_id']?>" <?php if(in_array($s['cs_id'],$selstores)) echo 'checked'?>> &nbsp;<?php echo $s['cs_name'];?></label></li>
	  <?php
			}
      }
       ?>
     </ul>
</div>


<table width="100%" height="50" border="0" cellpadding="0" cellspacing="0" class="clear">
  <tr>
    <td class="CsearchLeft">&nbsp;</td>
    <td align="center" class="CsearchCenter">

    <?php echo lang("select_location")?>:<input name="selstore" type="text" class="ClocationInput" onclick="showmitistores();" id="selstore" value="<?php if(count($selstores)==0){ echo "--"; }else { if(count($selstores)==count($stores)) echo lang("all_locations"); else echo ""; }?>" />

     <?php echo lang("a_sdate")?>：
      <input name="sdate" type="text" class="CtimeInput" id="sdate" value="<?php echo $sdate;?>" onclick="showcalendar();"/>
      <?php echo lang("a_edate")?>：
      <input name="edate" type="text" class="CtimeInput" id="edate" value="<?php echo $edate;?>" onclick="showcalendar();" />
      <input name="button" type="submit" class="btnblue" id="button" value="<?php echo lang("search_report")?>" /></td>
    <td class="CsearchRight">&nbsp;</td>

  </tr>
</table>
</form>
<br />
<br />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><div class="table2TitleBg">
      <div class="table2TitleBg2">
      <?php if($type!='time'){?>
      <div style="float:right;margin-right:10px;">

      <a href="javascript:exportImage(0);"><img src="<?php echo $www_site_url?>/public/images/export_image-icon.gif" border="0" title="export Image"></a>
      <a href="javascript:print(0);"><img src="<?php echo $www_site_url?>/public/images/print_icon.jpg" border="0" title="Print"></a>
      </div>
      <?php }?>
      	<div class="table2Title"><div class="table2TitleLeft"><span> <?php echo lang("bar_graph")?></span></div></div>
      </div>

    </div></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="table2LeftBorder"></td>
        <td>
        <p align="center">

<?php if($type=='time'){

	if(count($selstores)>0 && is_array($questions)){
echo "<pre>";
print_r($questions);
		foreach ($questions as $k=> $ques){

			?>

      <div style="float:right;margin-right:10px;">

      <a href="javascript:exportImage(<?php echo $ques['rq_id']?>);"><img src="<?php echo $www_site_url?>/public/images/export_image-icon.gif" border="0" title="export Image"></a>
      <a href="javascript:print(<?php echo $ques['rq_id']?>);"><img src="<?php echo $www_site_url?>/public/images/print_icon.jpg" border="0" title="Print"></a>
      </div>

	<div id="flashcontent<?php echo $ques['rq_id']?>">
		<strong>You need to upgrade your Flash Player</strong>
	</div>
	<script type="text/javascript">
		// <![CDATA[
		var so = new SWFObject("<?php echo $www_site_url?>/public/flash/amcolumn.swf", "amcolumn<?php echo $ques['rq_id']?>", "100%", "400px", "8", "#ffffff");
		so.addParam("wmode", "transparent");
		so.addVariable("path", "<?php echo $www_site_url?>/public/flash/");
		 so.addVariable("chart_id", "amcolumn<?php echo $ques['rq_id']?>");
		so.addVariable("settings_file", encodeURIComponent("<?php echo $www_site_url?>/public/flash/amcolumn_settings2.xml?342"));
		so.addVariable("data_file", encodeURIComponent("<?php echo $www_site_url?>/admin.php?action=chart&view=timedata&c_id=<?php echo $corp['c_id'];?>&b_id=<?php if(isset($brand_id))echo $brand_id;?>&rq_id=<?php echo $ques['rq_id']?>&sdate=<?php echo $sdate?>&edate=<?php echo $edate?>&selstores=<?php echo join(",",$selstores);?>&selbrands=<?php echo join(",",$selbrands);?>&group=service,environment,product"));
		so.addVariable("preloader_color", "#ffffff");
		so.addVariable("additional_chart_settings", encodeURIComponent("<settings><labels><label lid='0'><text><![CDATA[<b><?php echo "Q".($k+1).'. '.$ques['rq_question'].$chart_title?></b>]]></text></label></labels></settings>"));
		so.write("flashcontent<?php echo $ques['rq_id']?>");
		// ]]>
	</script>
	<?php
		}
	}else{
		echo lang("selectone").lang("brands");
	}
	?>
<?php
}else {
//在这里判断是否有 product、环境、产品，根据实际情况传入适当的参数
if(!isset($brand_id)) $brand_id='';
$url = "$www_site_url/admin.php?action=chart&view=overalldata&scoretype=$type&c_id=".$corp['c_id']."&b_id=$brand_id&sdate=$sdate&edate=$edate&selstores=".join(",",$selstores)."&selbrands=".join(",",$selbrands)."&group=service,environment,product";

if( 2 == $sign){//元祖
	$url = "$www_site_url/admin.php?action=chart&view=overalldata&scoretype=$type&c_id=".$corp['c_id']."&b_id=$brand_id&sdate=$sdate&edate=$edate&selstores=".join(",",$selstores)."&selbrands=".join(",",$selbrands)."&group=service,environment";
}
//echo "url=".$url;

?>
<div id="flashcontent">
				<strong>You need to upgrade your Flash Player</strong>
			</div>
	<script type="text/javascript">
		// <![CDATA[
		var so = new SWFObject("<?php echo $www_site_url?>/public/flash/amcolumn.swf", "amcolumn0", "100%", "400px", "8", "#ffffff");
		so.addParam("wmode", "transparent");
		so.addVariable("path", "<?php echo $www_site_url?>/public/flash/");
		 so.addVariable("chart_id", "amcolumn0");
		so.addVariable("settings_file", encodeURIComponent("<?php echo $www_site_url?>/public/flash/amcolumn_settings.xml?102"));
		//so.addVariable("data_file", encodeURIComponent("<?php echo $www_site_url?>/admin.php?action=chart&view=overalldata&scoretype=<?php echo $type;?>&c_id=<?php echo $corp['c_id'];?>&b_id=<?php if(isset($brand_id))echo $brand_id;?>&sdate=<?php echo $sdate?>&edate=<?php echo $edate?>&selstores=<?php echo join(",",$selstores);?>&selbrands=<?php echo join(",",$selbrands);?>&group=service,environment,product"));
		so.addVariable("data_file", encodeURIComponent("<?php echo $url?>"));
		so.addVariable("preloader_color", "#ffffff");
		so.addVariable("additional_chart_settings", encodeURIComponent("<settings><labels><label lid='0'><text><![CDATA[<b><?php echo $chart_title?></b>]]></text></label></labels><guides><max_min>true</max_min><guide><title><?php echo lang("interal_avg");?></title><start_value><?php echo $internal_average;?></start_value><inside>true</inside><text_color>#999999</text_color><behind>true</behind><text_size>12</text_size> <width>1</width><color>#999999</color> </guide></guides><graphs><graph gid='0'><title><?php echo lang("environment")?></title></graph><graph gid='1'><title><?php echo lang("service")?></title></graph><graph gid='2'><title><?php echo lang("product")?></title></graph></graphs></settings>"));

		so.write("flashcontent");
		// ]]>
	</script>
<?php }?>
        </p>
              <p>&nbsp;</p>
          <p>&nbsp;</p>
<script>
function print(id){
  document.getElementById("amcolumn"+id).printAsBitmap();
}
function exportImage(id) {
  document.getElementById("amcolumn"+id).exportImage('/plugins/export.php');
}

</script>
<div style="float:right;margin-right:10px;">
      <a href="javascript:showprintpage(1);"><img src="<?php echo $www_site_url?>/public/images/print_icon.jpg" border="0" title="Print"></a>
      </div>
      
<!--startprint1-->
<?php if($type=='time'){?>
          <table width="100%" border="0" cellpadding="0" cellspacing="1" class="CinitData">
                <tr>
                  <td colspan="5" class="title"><?php echo lang("original_figures")?></td>
                </tr>
                 <tr>
                  <td><?php echo lang("an_date")?></td>
                  <td><?php echo lang("assignment")?></td>
                  <?php
                  if(is_array($questions)){
		foreach ($questions as $k=>$ques){

			?>
                  <td><?php echo "Q".($k+1)?> <?php echo lang("an_date")?></td>
                 <?php }
                  }?>
                </tr>
                <?php
                if(isset($assignments)){
                	foreach ($assignments as $v){
                		?>
                <tr>
                  <td width="15%"><?php echo $v['day']?></td>
                  <td width="40%"><a href="<?php echo $www_site_url?>/client.php/home/reportcomplete/re_id/<?php echo $v['re_id']?>/a_id/<?php echo $v['a_id']?>" target="_blank"><?php echo stripslashes($v['a_title'])?></a></td>
                  <?php if(isset($v['times']) && is_array( $v['times'])){
                  	foreach ( $v['times'] as $t){
                  		?>

                  <td width="15%"><?php echo $t?></td>
					<?php
                  	}
                  }
                  	?>
                </tr>
                <?php
                	}
                }
                ?>

              </table>
     <?php
}else {
//在这里判断是否有 product、环境、产品，根据实际情况传入适当的参数
?>
         <table width="100%" border="0" cellpadding="0" cellspacing="1" class="CinitData">
                <tr>
                  <td colspan="6" class="title"><?php echo lang("original_figures")?></td>
                </tr>
                 <tr>
                  <td><?php echo lang("an_date")?></td>
                  <td><?php echo lang("assignment")?></td>

                  <td><?php echo lang("environment")?></td>
                  <td><?php echo lang("service")?></td>
                  <?php if(2 != $sign){ ?>
                  <td><?php echo lang("product")?></td>
                  <?php } ?>
                  <td><?php echo lang("general")?></td>

                </tr>
                <?php
                if(isset($assignments)){
                	foreach ($assignments as $v){
                		?>
                <tr>
                  <td width="15%"><?php echo $v['day']?></td>
                  <td width="40%"><a href="<?php echo $www_site_url?>/client.php/home/reportcomplete/re_id/<?php echo $v['re_id']?>/a_id/<?php echo $v['a_id']?>" target="_blank"><?php echo stripslashes($v['a_title'])?></a></td>

                  <td width="15%"><?php echo $v['environment']?></td>
                   <td width="15%"><?php echo $v['service']?></td>
                   <?php if(2 != $sign){ ?>
                  <td width="15%"><?php echo $v['product']?></td>
                  <?php } ?>
                  <td width="15%"><?php echo $v['general']?></td>


                </tr>
                <?php
                	}
                }
                ?>

              </table>
        <?php
               }

                ?>
<!--endprint1-->
          <p>&nbsp;</p></td>
        <td class="table2RightBorder"></td>
      </tr>

      <tr>
        <td class="table2BottomLeft"></td>
        <td class="table2Bottom"></td>
        <td class="table2BottomRight"></td>
      </tr>
    </table></td>
  </tr>
</table>
</div>
</div>

</div>
<?php include_once("footer.html")?>

<script type="text/javascript">
function outToPdf(oper){
	bdhtml = window.document.body.innerHTML;
	sprnstr = "<!--startprint"+oper+"-->";
	eprnstr = "<!--endprint"+oper+"-->";
	prnhtml = bdhtml.substring(bdhtml.indexOf(sprnstr)+18);
	prnhtml = prnhtml.substring(0,prnhtml.indexOf(eprnstr));

	//prnhtml = encodeURIComponent(prnhtml);
	//alert("html="+prnhtml);

	var url = "<?php echo $www_site_url?>/plugins/savetopdf.php";
	//window.location = url;


	//var url = "<?php echo $www_site_url?>/plugins/showpage.php";

	//window.document.body.innerHTML = prnhtml;
	//window.print();

	/*
	mini.ajax.post(url,function(r){
	//如果直接用window.open()，谷歌浏览器不会新弹出窗口，为了解决此问题，故这么写
	var w = window.open();
	w.opener = null;
	w.document.location = "<?php echo $www_site_url?>/plugins/printpage.php";},
	"c="+encodeURIComponent(prnhtml));
	*/

	mini.ajax.post(url, function(r){
		if(r == 'OK'){
			alert("Upload success.");
		}
	},
		"data="+encodeURIComponent(prnhtml)
	);

}

</script>
